#include "FollowCamComponent.h"
#include "..\Managers\RenderManager.h"
#include "PhysicsComponent.h"
#include "GameObject.h"
#include "..\Debug\DebugLog.h"

FollowCamComponent::FollowCamComponent(const std::string& p_cameraID)
{
	m_camera = RenderManager::getSingleton().getRenderEngine()->getCamera(p_cameraID);
	if (m_camera == nullptr)
		Debug::log("WARNING: Camera ID " + p_cameraID + " could not be found");
}

FollowCamComponent::~FollowCamComponent(void){}

void FollowCamComponent::init()
{
	m_physics = static_cast<PhysicsComponent*>(getOwner()->getComponent("PhysicsComponent"));
}

void FollowCamComponent::update(const GameTime& p_gameTime)
{
	m_camera->setTarget(m_physics->getPosition());
}